#include "ServoMotor.h"

void ServoMotor_TurnWithDegree(uint8_t degree) {
  uint16_t aa = (4500 + 100*(uint16_t)degree) / 9;
  LL_TIM_OC_SetCompareCH4(TIM1, aa);
}

void ServoMotor_TurnLeft(void) {
  ServoMotor_TurnWithDegree(10);
}
void ServoMotor_TurnRight(void) {
  ServoMotor_TurnWithDegree(160);
}
void ServoMotor_TurnStright(void) {
  ServoMotor_TurnWithDegree(80);
}

void ServoMotor_ExampleLoop(void) {
  while(1) {
    ServoMotor_TurnLeft();
    LL_mDelay(2000);
    ServoMotor_TurnStright();
    LL_mDelay(2000);
    ServoMotor_TurnRight();
    LL_mDelay(2000);
    ServoMotor_TurnStright();
    LL_mDelay(2000);
  }
}
